package com.levi.producer;

import com.alibaba.fastjson.JSON;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * @author shentong
 * @since 2022/6/9 4:16 PM
 */
@Component
public class OrderProducer {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;


    public void send(Object obj) {
        rocketMQTemplate.sendMessageInTransaction("group1",MessageBuilder.withPayload(JSON.toJSONString(obj)).build(),null);
    }

}
